<?php
include('top.php');
require_once('pasmy/dbwaarden.php');
/*echo "dbhost = $dbhost<br>";*/
echo "<br><br>";
$mysql_id = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($db, $mysql_id);
$jaartal = date("Y");

if(isset($_POST["gaan"])) {
	
/*foreach($_POST as $sleutel => $waarde) {
		echo "sleutel = $sleutel en waarde = |$waarde| <br>";
		}
exit;*/

$maanden = $_POST["maanden"];
if($maanden < 10) { $maanden = "0" . $maanden;}
$datu = $_POST["jaren"] . "-" . $maanden . "-" . $_POST["dagen"];

/* functie om week uit ingevoerde datum te halen*/
$datum = $_POST["dagen"] . "-" . $maanden . "-" . $_POST["jaren"];
//echo "datum = $datum<br>";

$ndatum = explode("-",$datum);
$date = mktime(0, 0, 0, $ndatum[1], $ndatum[0], $ndatum[2]); 
$week = (int)date('W', $date);
/*einde functie week uit datum */

echo "<strong><div style='text-align: center'>ingevoerde datum is gesitueerd in week $week</div></strong><br>";


$driver =$_POST["driver"];
$datum = $datu;
$ref = addslashes($_POST["dossier"]); if(empty($ref)) { $ref = "&nbsp;";} else $ref = strtoupper($ref);
//$client = addslashes($_POST["client"]);$client = strtolower($client);$client = ucwords($client);
$expediteur = addslashes($_POST["expedi"]);$expediteur = strtolower($expediteur);$expediteur = ucwords($expediteur);
$bestemmeling = addslashes($_POST["bestem"]);$bestemmeling = strtolower($bestemmeling);$bestemmeling = ucwords($bestemmeling);
$plaats = addslashes($_POST["ville"]);$plaats = strtolower($plaats);$plaats = ucwords($plaats);//echo "plaats = $plaats<br>";
$laadplaats = addslashes($_POST["laadplaats"]);$laadplaats = strtolower($laadplaats);$laadplaats = ucwords($laadplaats);
$colis = $_POST["colis"];if(empty($colis)) { $colis = "&nbsp;";}
$pal = $_POST["pal"];if(empty($pal)) { $pal = "&nbsp;";}
$mp = $_POST["mp"];if(empty($mp)) { $mp = "&nbsp;";}
$poids = $_POST["poids"];if(empty($poids)) { $poids = "&nbsp;";}
$prijs = $_POST["prix"];if(empty($prijs)) { $prijs = "vide";}else{ $prijs=number_format($prijs,2); }
$opmerkingen = addslashes($_POST["opm"]);if(empty($opmerkingen)) { $opmerkingen = "&nbsp;";}
$cmr = addslashes($_POST["cmr"]);if(empty($cmr)) { $cmr = "&nbsp;";}
$nrpl = $_POST["nrpl"];

/*switch($nrpl) {
	
		case "447CKA59":
			$ligne = "603";
		break;
		case "1-BFQ 358":
			$ligne = "601";
		break;
		case "3285YC74":
			$ligne = "603";
		break;
		case "KLL 248":
			$ligne = "602";
		break;
		case "Affretement":
			$ligne = "649";
		break;
		case "1-AXF 692":
			$ligne = "610";
		break;
		case "1-AXF 706":
			$ligne = "649";
		break;
		
		default: 
			$ligne = "600";
	}	*/


$sqql = "select ligne from nummerplaten where nrpl = '$nrpl'";
$ress = mysql_query($sqql, $mysql_id);
while ($row = mysql_fetch_row($ress)) {
	$ligne = $row[0];
}

//echo "sqql = $sqql<br>";

if($_POST["diesel"] != "-----") {
		$gprijs = $_POST["diesel"]/100;
		$newprix = number_format($prijs + (($prijs * $gprijs)-$prijs),2);
		//echo "prijs incl diesel = $newprix<br>";
	}
if($_POST["diesel"] == "-----") { $newprix = "0"; $newprix = number_format($newprix,2); }


$clientje = $_POST["klantje"];
$sql1 = "select client from clienten where id = '$clientje'";
			//echo "sql1 = $sql1<br>";
$res1 = mysql_query($sql1, $mysql_id);
		while ($row1 = mysql_fetch_row($res1)) 
		{
			$clientje=$row1[0];
		}
		fout($mysql_id);
$clientje = addslashes($clientje);
$clientje = strtolower($clientje);
$clientje = ucwords($clientje);
		//echo "client = $clientje en gedaan <br>";exit;
$client = $clientje;
	

if($_POST["dan"] == "Oui") {
	$dan = "D&eacute;poser &agrave; Neuville";	
	$opmerkingen = $opmerkingen . $dan;
}
$waardb = "vnzvrn" . $_POST["jaren"];

$sql = "INSERT into $waardb (datum,ref,client,expediteur,bestemmeling,plaats,colis,pal,mp,poids,prijs,opmerkingen,driver,week,laadplaats,cmr,gasoil,nrpl,ligne)
VALUES ('$datum','$ref','$client','$expediteur','$bestemmeling','$plaats','$colis','$pal','$mp','$poids','$prijs',
'$opmerkingen','$driver','$week','$laadplaats','$cmr','$newprix','$nrpl','$ligne')";

/* hier wordt alles weggeschreven */
$res = mysql_query($sql, $mysql_id);

/*echo "sql = $sql<br>";
echo "datum = $datum<br>";
echo "ref = $ref<br>";
echo "client = $client<br>";
echo "expediteur = $expediteur<br>";
echo "bestemmeling = $bestemmeling<br>";
echo "plaats = $plaats<br>";
echo "colis = $colis<br>";
echo "pal = $pal<br>";
echo "mp = $mp<br>";
echo "poids = $poids<br>";
echo "prijs = $prijs<br>";
echo "opmerkingen  = $opmerkingen<br>";
echo "driver = $driver<br>";
echo "week = $week<br>";*/


?>
<div style="text-align: center"><br /><h3><?php echo $verwerkt[$taal];?></h3></div><br />
<div style="text-align: center"><a href="porteur.php" class="linkblue"><h3><?php echo $meerinvoer[$taal];?></h3></a></div>
<?php
}
else {
/* Chauffeurs selectie */
$chtel = 0;
$sql = "select `lang` from chauffeurs where categorie = 'porteur' and weg != 'ja'";
$res = mysql_query($sql, $mysql_id);
while ($row = mysql_fetch_row($res)) {
	$chauffeurs[$chtel]=$row[0];
	$chtel++;
	}
$chtel = 0;
asort($chauffeurs);
if($taal == fr) {
$maanden = array("-----","Janvier","Fevrier","Mars","Avril","Mai","Juin","Julliet","Aout","Septembre","Octobre","Novembre","Decembre");
}
else {
$maanden = array("-----","Januari","Februari","Maart","April","Mei","Juni","Juli","Augustus","September","Oktober","November","December");
}
$gasoil = array("-----","2.50","3.00","3.50","4.00","4.50","5.00","5.50","6.00","6.50","7.00","7.50","8.00");
$chtel = 0;
//$sql = "select nrpl from nummerplaten where klas='porteur' and firma='vanzeveren'";
$sql = "select nrpl from nummerplaten";
$res = mysql_query($sql, $mysql_id);
while ($row = mysql_fetch_row($res)) {
	$kenteken[$chtel]=$row[0];
	$chtel++;
	}
asort($kenteken);

/*$kenteken[$chtel]="- - - - - - - - - -";
$chtel++;

$sql = "select nrpl from nummerplaten where klas='trekker' and firma='vanzeveren'";
$res = mysql_query($sql, $mysql_id);
while ($row = mysql_fetch_row($res)) {
	$kenteken[$chtel]=$row[0];
	$chtel++;
	}
$kenteken[$chtel]="- - - - - - - - - -";
$chtel++;


$sql = "select nrpl from nummerplaten where firma='roussel'";
$res = mysql_query($sql, $mysql_id);
while ($row = mysql_fetch_row($res)) {
	$kenteken[$chtel]=$row[0];
	$chtel++;
	}*/

$dagen = array("-----","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31");
?>






<form action="porteur.php" method="post">





<table align="center">
<tr><td class="zones">Chauffeur</td>
<td>&nbsp;&nbsp;&nbsp;</td>
<td class="zones"><select name="driver">
<?php
while(list($key, $val)=each($chauffeurs)) {	 
		echo '<option value="'.$val.'">'.$val.'</option>';
}
?></select>&nbsp;&nbsp;
<select name="nrpl">
<?php
while(list($key, $val)=each($kenteken)) {
	if (isset($nrpl) && ($nrpl == $val)) {
		echo '<option value="'.$val.'" selected>'.$val.'</option>';
	} else {
		echo '<option value="'.$val.'">'.$val.'</option>';
	}
}
?></select>



</td></tr>
<tr>
<td class="zones">Datum</td>
<td>&nbsp;&nbsp;&nbsp;</td>
<td class="zones">
<select name="dagen">
<?php
while(list($key, $val)=each($dagen)) {
	if (isset($dagen) && ($dagen == $val)) {
		echo '<option value="'.$val.'" selected>'.$val.'</option>';
	} else {
		echo '<option value="'.$val.'">'.$val.'</option>';
	}
}
?></select>
<select name="maanden">
<?php
while(list($key, $val)=each($maanden)) {
	if (isset($maanden) && ($maanden == $val)) {
		echo '<option value="'.$key.'" selected>'.$val.'</option>';
	} else {
		echo '<option value="'.$key.'">'.$val.'</option>';
	}
}
?></select>

<input type="text" name="jaren" value="<?php echo $jaartal;?>" size="4" maxlength="4" />


</td>
</tr>
<tr>
<td class="zones"><?php echo $referentie[$taal];?></td>
<td>&nbsp;&nbsp;&nbsp;</td>
<td class="zones"><input type="text" name="dossier" size="20" maxlength="20" /></td>
</tr>

<tr>
<td class="zones">CMR</td>
<td>&nbsp;&nbsp;&nbsp;</td>
<td class="zones"><input type="text" name="cmr" size="20" maxlength="20" /></td>
</tr>

<tr>
<?php
$sql = "select client,id from clienten";
$res = mysql_query($sql, $mysql_id);
while ($row = mysql_fetch_row($res)) {
	$clienten[$row[1]]=$row[0];
	}
asort($clienten);
$clienten = array_unique($clienten);
?>
<td class="zones"><?php echo $klant[$taal];?></td>
<td>&nbsp;&nbsp;&nbsp;</td>
<td class="zones">
<select name="klantje">
<?php
while(list($key, $val)=each($clienten)) {
	 
		echo '<option value="'.$key.'">'.$val.'</option>';
	
}
?></select>
</tr>
<tr>
<td class="zones"><?php echo $verzender[$taal];?></td>
<td>&nbsp;&nbsp;&nbsp;</td>
<td class="zones"><input type="text" name="expedi" size="35" /></td>
</tr>

<tr>
<td class="zones"><?php echo $laplaats[$taal];?></td>
<td>&nbsp;&nbsp;&nbsp;</td>
<td class="zones"><input type="text" name="laadplaats" size="35" /></td>
</tr>

<tr>
<td class="zones"><?php echo $bestemmeling[$taal];?></td>
<td>&nbsp;&nbsp;&nbsp;</td>
<td class="zones"><input type="text" name="bestem" size="35" /></td>
</tr>
<tr>
<td class="zones"><?php echo $plaats[$taal];?></td>
<td>&nbsp;&nbsp;&nbsp;</td>
<td class="zones"><input type="text" name="ville" size="35" /></td>
</tr>
<tr>
<td class="zones"><?php echo $colis[$taal];?></td>
<td>&nbsp;&nbsp;&nbsp;</td>
<td class="zones"><input type="text" name="colis" size="4" maxlength="4" /></td>
</tr>
<tr>
<td class="zones"><?php echo $vloermeter[$taal];?></td>
<td>&nbsp;&nbsp;&nbsp;</td>
<td class="zones"><input type="text" name="mp" size="6" maxlength="6" /></td>
</tr>
<tr><td class="zones"><?php echo $pals[$taal];?></td>
<td>&nbsp;&nbsp;&nbsp;</td>
<td class="zones"><input type="text" name="pal" size="5" maxlength="3" /></td>
</tr>
<tr><td class="zones"><?php echo $gewicht[$taal];?></td>
<td>&nbsp;&nbsp;&nbsp;</td>
<td class="zones"><input type="text" name="poids" size="6" maxlength="6" /></td>
</tr>
<tr>
<td class="zones"><?php echo $pprijs[$taal];?></td>
<td>&nbsp;&nbsp;&nbsp;</td>
<td class="zones"><input type="text" name="prix" size="7" maxlength="7" />
&nbsp;&nbsp;&nbsp;&nbsp;Surcharge Gasoil&nbsp;&nbsp;<select name="diesel"> 
<?php
while(list($key, $val)=each($gasoil)) {
	if (isset($diesel) && ($diesel == $val)) {
		echo '<option value="'.$val.'" selected>'.$val.'</option>';
	} else {
		echo '<option value="'.$val.'">'.$val.'</option>';
	}
}
?></select>
</td>
</tr>
<tr>
<td class="zones"><?php echo $dep[$taal];?></td>
<td>&nbsp;&nbsp;&nbsp;</td>
<td class="zones"><input type="radio" name="dan" value="Oui" /><?php echo $ja[$taal];?> &nbsp;&nbsp;<input type="radio" name="dan" value="Non" checked="checked" /><?php echo $neen[$taal];?></td>
</tr>
<tr>
<td class="zones"><?php echo $opmerkingen[$taal];?></td>
<td>&nbsp;&nbsp;&nbsp;</td>
<td class="zones"><input type="text" name="opm" size="100" /></td>
</tr>
<tr>
<td class="zones"></td>
<td>&nbsp;&nbsp;&nbsp;</td>
<td class="zones"></td>
</tr>
<tr>
<td class="zones" colspan="3"><div style="text-align: center"><input type="submit" name="gaan" value="<?php echo $toevoegen[$taal];?>" /></div></td>
<!-- <td>&nbsp;&nbsp;&nbsp;</td>
<td class="zones"></td> -->
</tr>
</table>
</form>
 
		
<?php
}
include('footer.php');
?>